package cn.wizzer.app.crown.modules.models;

import cn.wizzer.app.crown.modules.models.caches.CrownMatchChampion;
import cn.wizzer.app.crown.modules.models.enums.MatchTypeEnum;
import cn.wizzer.framework.base.model.BaseModel;
import lombok.Data;
import org.nutz.dao.entity.annotation.*;
import org.nutz.dao.interceptor.annotation.PrevInsert;

import java.io.Serializable;
import java.util.Date;
import java.util.List;

/**
 * 联赛
 */
@Data
@Table("crown_league")
public class CrownLeague extends BaseModel implements Serializable {
    @Column
    @Name
    @Comment("ID")
    @ColDefine(type = ColType.VARCHAR, width = 32)
    @PrevInsert(els = {@EL("uuid()")})
    private String id;

    /**
     * 赛事ID
     */
    @Column("champion_id")
    @Comment("联赛ID")
    @ColDefine(type = ColType.VARCHAR, width = 16)
    private String championId;

    /**
     * 联赛类型 足球FT 篮球BK
     */
    @Column
    @Comment("联赛类型")
    @ColDefine(type = ColType.VARCHAR, width = 32)
    private MatchTypeEnum type;

    /**
     * 联赛名称
     */
    @Column
    @Comment("联赛名称")
    @ColDefine(type = ColType.VARCHAR, width = 128)
    private String league;

    /**
     * 冠军名称
     */
    @Column("champion_name")
    @Comment("冠军名称")
    @ColDefine(type = ColType.VARCHAR, width = 128)
    private String championName;


    /**
     * 比赛日期
     */
    @Column("date_time")
    @Comment("日期")
    @ColDefine(type = ColType.DATETIME, width = 32)
    private Date dateTime;

    /**
     * 阶段 进行中:running、已结束：finished
     */
    @Column
    @Comment
    @ColDefine(type = ColType.VARCHAR, width = 32)
    private String stage;


    /**
     * 版本号
     */
    @Column
    @Comment("版本号")
    private Integer version;


    /**
     * 联赛中的玩法细项
     */
    private List<CrownMatchChampion> matchChampionList;


    /**
     * 赛果详情
     */
    private List<CrownLeagueResult> subResults;

    /**
     * 赛果列表用
     */
    private String results;

    public long getDateTimestamp() {
        return null == dateTime?0:dateTime.getTime();
    }
}
